<template>
    <div class="mui-numbox" data-numbox-min='1'>
		<button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		<input id="test" class="mui-input-numbox" type="number" :value="initCount" ref="numbox" @change="countChange" readonly/>
		<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>
<script>
import mui from '../../lib/mui/js/mui'
export default {
    mounted(){
         // 初始化数字选择框组件
        mui(".mui-numbox").numbox();
    },
    methods:{
        //如果购买数量发生变化，就把最新的值传到store中去
        countChange(){  
            // console.log(this.$refs.numbox.value)
            var goodsinfo = {
                id : this.goodsid,
                count : this.$refs.numbox.value
            }
            this.$store.commit('updateCar', goodsinfo)
        }
    },
    props:["initCount","goodsid"]
   
}
</script>
<style lang="scss" scoped>

</style>

